package com.tao.spell.group.controller;

import com.tao.spell.common.utils.PageUtils;
import com.tao.spell.common.utils.R;
import com.tao.spell.group.entity.MiaoshaOrderEntity;
import com.tao.spell.group.service.MiaoshaOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 
 *
 * @author lc
 * @email sunlightcs@gmail.com
 * @date 2021-09-10 20:29:10
 */
@RestController
@RequestMapping("group/miaoshaorder")
public class MiaoshaOrderController {
    @Autowired
    private MiaoshaOrderService miaoshaOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miaoshaOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orderId}")

    public R info(@PathVariable("orderId") Integer orderId){
		MiaoshaOrderEntity miaoshaOrder = miaoshaOrderService.getById(orderId);

        return R.ok().put("miaoshaOrder", miaoshaOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody MiaoshaOrderEntity miaoshaOrder){
		miaoshaOrderService.save(miaoshaOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")

    public R update(@RequestBody MiaoshaOrderEntity miaoshaOrder){
		miaoshaOrderService.updateById(miaoshaOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody Integer[] orderIds){
		miaoshaOrderService.removeByIds(Arrays.asList(orderIds));

        return R.ok();
    }

}
